<template>
  <a-button
    v-if="!option.hide"
    v-has
    :type="typeCorrect(name, option.type)"
    :disabled="option.disabled"
    :loading="option.loading"
    @click="option.click? option.click(option, $event) : ''"
  >
    <template #icon v-if="option.icon">
      <component :is="option.icon" :key="option.icon"/>
    </template>
    {{option.name}}
  </a-button>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { ActionsOptionItem } from '@/components/typing';

export default defineComponent({
  name: 'ActionButton',
  props: {
    name: String,
    option: Object as PropType<ActionsOptionItem>,
    typeCorrect: Function
  },
});
</script>